package com.bsoft.gol.hcs.specialist.service.impl;

import ctd.controller.exception.ControllerException;
import ctd.spring.boot.annotation.SsdevService;
import ctd.util.annotation.RpcService;
import com.bsoft.gol.hcs.his.service.IIndexHisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import com.bsoft.gol.hcs.specialist.bean.request.QueryDictionaryListByKeyReq;
import com.bsoft.gol.hcs.specialist.bean.request.QueryIndexTypeReq;
import com.bsoft.gol.hcs.specialist.bean.response.IndexTypeParameterResp;
import com.bsoft.gol.hcs.specialist.dao.FusBaseDictionaryDAO;
import com.bsoft.gol.hcs.specialist.entity.FusBaseDictionary;
import com.bsoft.gol.hcs.specialist.service.IDictionaryService;

import java.util.List;

/**
 * @Author:FangZhiyi
 * @Description
 * @Data Created in 2020/7/28 9:38
 * @Moddified By:
 */
@SsdevService("dictionary")
public class DictionaryServiceImpl implements IDictionaryService {
    @Autowired
    FusBaseDictionaryDAO fusBaseDictionaryDAO;
    @Autowired
    IIndexHisService indexHisService;

    @Override
    @RpcService
    public List<FusBaseDictionary>  queryDictionaryListByKey(QueryDictionaryListByKeyReq dictionaryListByKeyReq) throws ControllerException {
        List<FusBaseDictionary> dictionaryList = fusBaseDictionaryDAO.queryDictionaryListByKey(dictionaryListByKeyReq.getDicKeyCode());
        if (!CollectionUtils.isEmpty(dictionaryList)) {
            return dictionaryList;
        }
        throw new ControllerException("暂无数据");
    }

    @Override
    @RpcService
    public List<IndexTypeParameterResp> getIndexTypeParameter(QueryIndexTypeReq req) throws ControllerException{
        try {
            return indexHisService.getIndexTypeParameter(req).getData();
        } catch (Exception e) {
            e.printStackTrace();
            throw new ControllerException("暂无数据");
        }
    }
}
